package com.chenlonghai.sbmybatis.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baidu.ueditor.ActionEnter;

@Controller
public class PageJumpController {
    @RequestMapping("/admin")
    private String showadmin(){
        return "index";
    }
    @RequestMapping("/index")
    private String showPageIndex(){
        return "index";
    }
    @RequestMapping("/addActivity")
    private String showPageAddAct(){
        return "addActivity";
    }
 
    @RequestMapping("/addBanner")
    private String showPageAddBanner(){
        return "addBanner";
    }
    
    @RequestMapping("/addCase")
    private String showPageAddCase(){
        return "addCase";
    }
    

    
    @RequestMapping(value="/config")
    public void config(HttpServletRequest request, HttpServletResponse response) throws JSONException {
        response.setContentType("application/json");
        String rootPath = request.getSession().getServletContext().getRealPath("/");
        System.err.println(rootPath);
        try {
            String exec = new ActionEnter(request, rootPath).exec();
            PrintWriter writer = response.getWriter();
            writer.write(exec);
            writer.flush();
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
 
    }
}
